#pragma once

#include <iostream>
#include <vector>
#include <fstream>
using namespace std;



struct TokenCreator
{
    vector<string> names;

    void output(string path, string fileName)
    {
        ofstream ofs(path+fileName+".hpp");

        ofs << "#pragma once" << endl;
        ofs << "#include <string>" << endl;
        ofs << "struct Token{" << endl;
        ofs << "\t" << "enum TokenType{" << endl;

        for (int i = 0; i<names.size(); i++)
        {
            ofs << "\t\t" << names[i] << " = " << i << "," << endl;
        }
        ofs << "\t" << "};" << endl;
        ofs << "\t" << endl;
        ofs << "\t" << "const static std::string enumToName[];" << endl;

        ofs << "\t" << "std::string getName(){" << endl;
        ofs << "\t\t" << "return enumToName[type];" << endl;
        ofs << "\t" << "}" << endl;
        ofs << endl;

        ofs << "\t" << "TokenType type;" << endl;
        ofs << "\t" << "char* textStart;" << endl;
        ofs << "\t" << "char* textEnd;" << endl;
        ofs << "\t" << "int line;" << endl;
        ofs << "\t" << "int row;" << endl;


        ofs << "};" << endl;

        ofs.close();

        ofs.open(path+fileName+".cpp");
        ofs << "#include \"" << fileName << ".hpp" << "\"" << endl;
        ofs << endl;

        ofs << "const std::string Token::enumToName[] = {";
        for (int i = 0; i<names.size()-1; i++)
        {
            ofs << "\"" << names[i] << "\",";
        }
        ofs << "\"" << names[names.size()-1] << "\"";
        ofs << "};" << endl;

        ofs.close();
    }

};
